/*
 * DebugEx_F.h
 *
 *  Created on: 2014年9月5日
 *      Author: root
 */

#ifndef DEBUGEX_F_H_
#define DEBUGEX_F_H_

#include <assert.h>
#include <stdio.h>
#include <comm_lib_f.h>


#ifdef DEBUG
//#define Dprintf(...)			CDebugEx_F::Printf(__VA_ARGS__)
#endif //DEBUG


#define _TOSTR(str)		#str
#define TOSTR(str)		_TOSTR(str)


void dbg_stdout_array(const void* pdata,U16 len);

//use stdout as debug output
//Dsop means Debug standard out Print
//Want to use Dsop,remember to define DEBUG_F
//Dps means Debug check statement pass
//check if our program is block at some statement
#ifdef DEBUG_F
#define Dsop(...)					fprintf(stdout,__VA_ARGS__)
#define Dps(statement)			Dsop(TOSTR(pre enter [statement]\n)); statement; Dsop(TOSTR(pass [statement]\n));
#define darr(p,len)				dbg_stdout_array(p,len)
#define depos(msg)				Dsop("[%s:%d] %s\n%s",__FILE__, __LINE__, __ASSERT_FUNCTION,msg)
#else
#define Dsop(...)					((void) 0)
#define Dps(statement)			statement
#define darr(p,len)				((void) 0)
#define depos(msg)				((void) 0)
#endif//DEBUG



class debugsf_t
{
public:
	static int open(int fd);
	static int open(FILE* pFile);
	static int close();
	static int printf(const char* ch,...);
};


#define Oprintf(obj,...)		(obj).Printf(__VA_ARGS__)

class debugf_t
{
protected:
	FILE* _pFile;

public:
	int open(int fd);
	int open(FILE* pFile);
	int close();
	int printf(const char* ch,...);
};


#endif /* DEBUGEX_F_H_ */
